package com.hkts.naturalgas.mybaitsPlus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 字段填充审计
 * @author Exrick
 */
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("come to insert fill .........");

        this.setFieldValByName("createTime", LocalDateTime.now(), metaObject);

        this.setFieldValByName("updateTime",  LocalDateTime.now(), metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("come to update fill .......");

        this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject);
    }
}

